class Solution:
    def toGoatLatin(self, sentence: str) -> str:
        words = sentence.split()
        result = ''
        vowel = 'aeiouAEIOU'
        for i, word in enumerate(words):
            if word[0] in vowel:
                word += 'ma'
            else:
                word = word[1:] + word[0] + 'ma'
            word += 'a' * (i + 1)
            result += ' ' + word
        result = result[1:]
        return result
